
<?php
use yii\widgets\ActiveForm;
?>
<?php  $form = ActiveForm::begin(['enableAjaxValidation' => false,'enableClientValidation' => true,'options'=>['class'=>'form-validate']]); ?>
       <table class="yx-course-info">
        <tr><td width="180" align="right">订单实付总金额：</td> <td><?=\yii\helpers\Html::encode($model->final_amount);?></td></tr>
        <tr><td width="180" align="right">奖学金余额：</td> <td><?=\yii\helpers\Html::encode($customer->scholarship_available);?></td></tr>
        <tr><td width="180" align="right">账户金额：</td> <td><?=\yii\helpers\Html::encode($customer->account);?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <?php if(($customer->scholarship_available+$customer->account) < $model->final_amount):?><a href="javascript:;" id="gorecharge" style="color:red" data-url="<?=\common\components\helpers\Fun::url(['customer/details','id'=>$customer->id,'orders_id'=>$model->id])?>">去充值</a> <?php endif;?></td></tr>
        <tr>
            <td width="180" align="right"><?=$model->attributeLabels()['scholarship_money']; ?>：</td>
            <td><?= $form->field($model, 'scholarship_money', ['template' => '{input}{error}{hint}'])->textInput(['class' => 'input-text','readonly'=>'readonly']) ?></td>
        </tr>
       <tr>
           <td width="180" align="right"><?=$model->attributeLabels()['cash_money']; ?>：</td>
           <td><?= $form->field($model, 'cash_money', ['template' => '{input}{error}{hint}'])->textInput(['class' => 'input-text','readonly'=>'readonly']) ?></td>
       </tr>
       </table>
<?php  ActiveForm::end(); ?>
<?php
$js=<<<JS
    var account = $customer->scholarship_available+$customer->account;
    var order_account = $model->final_amount;
   $(document).on('click','#dosubmit',function(e){
       e.preventDefault();
       if(account < order_account){
          alert('余额不足请先充值');
          return false;
       }else{
           $('#paystatus-form').submit();
       }
   });

   $('#gorecharge').click(function(){
       var url = $(this).data('url');
      window.top.$('iframe[name=main-iframe]',window.top.$('#main-tabs').tabs('getSelected').panel('body'))[0].contentWindow.location.href=url;
      setTimeout("window.top.clearDialog();", 0);
    });
JS;
\Yii::$app->view->registerJs($js);
?>
